<?php
namespace app\facility\model;

use think\Model;
use think\Db;
use think\Cache;
class Billboard extends Model
{
    protected $table = 'billboard';

    public function getRelationInfo($vc_id)
    {
        // 查询设备容联云账号
        $where = ['b.device_id'=>$vc_id];
        $user_info = Db::table('billboard')->alias('b')
                                    ->where($where)
                                    ->join('user_relation_billboard ub', 'ub.billboard_id = b.id', 'LEFT')
                                    ->join('ronglian_account ra', 'ra.user_id = ub.user_id', 'LEFT')
                                    ->field('b.id as pid, ra.voipAccount, ra.user_id, b.standard_img_id, b.begin_time, b.end_time, b.is_monitor, b.night_img_id, b.thum_vista_img, b.name as bname')
                                    ->find();
        if ($user_info['user_id'] == 33) {
            $receiver = Db::table('user')->alias('u')->where('u.isDemo', 1)->join('ronglian_account ra', 'ra.user_id = u.id')->column('ra.voipAccount');
            $receiver = implode(',', $receiver);
        } else {
            $receiver = $user_info['voipAccount'];
        }
        $return['user_info'] = $user_info;
        $return['receiver'] = $receiver;
        return $return;
    }






    
}